package pers.chao.tool.tree;

import java.util.*;

/**
 * Description:
 *
 * @author W.Chao
 * @date 2020/12/26 2:18
 **/
public class TreeMapFactory {
	@SuppressWarnings("unchecked")
	public static <K, V> TreeMap<K, V> asc() {
		return new TreeMap<>((Comparator<? super K>) Comparator.naturalOrder());
	}

	@SuppressWarnings("unchecked")
	public static <K, V> TreeMap<K, V> desc() {
		return new TreeMap<>((Comparator<? super K>) Comparator.reverseOrder());
	}

	@SuppressWarnings("unchecked")
	public static <K, V> TreeMap<K, V> asc(Map<K,V> initMap) {
		TreeMap<K,V> treeMap = new TreeMap<>((Comparator<? super K>) Comparator.naturalOrder());
		treeMap.putAll(initMap);
		return treeMap;
	}

	@SuppressWarnings("unchecked")
	public static <K, V> TreeMap<K, V> desc(Map<K,V> initMap) {
		TreeMap<K,V> treeMap = new TreeMap<>((Comparator<? super K>) Comparator.reverseOrder());
		treeMap.putAll(initMap);
		return treeMap;
	}
}
